package basic;

//演示创建线程的基本方法

class Thread2 extends Thread{

    
    public Thread2(String name){

        super(name);
    }
    @Override
    public void run() {
        
        // 通过for循环展示执行的过程
        for(int i=0;i<100;i++){

            System.out.println(getName()+":"+i);
        }
    }

}

class Thread3 implements Runnable{

    @Override
    public void run() {
        
        // 通过for循环展示执行的过程
        for(int i=0;i<100;i++){

            System.out.println(Thread.currentThread().getName()+":"+i);
        }
    }
}

public class Thread1 {
    
    public static void main(String[] args) {
        
        // new Thread2("线程1").start();
        // new Thread2("线程2").start();

        Thread3 thread=new Thread3();

        new Thread(thread,"first").start();
        new Thread(thread,"second").start();
    }
}
